package com.net.oil.main.adapter;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import com.net.oil.TechnologySupport.TechnologyListFragment;
import com.net.oil.main.bean.TechnologyTypeBean;

import java.util.ArrayList;
import java.util.List;

/**
 * 作者：lch
 * 时间：2018/4/14 0014:上午 8:47
 * 邮箱：245850413@qq.com
 * 说明：
 */

public class TechnologyViewPagerAdapter extends FragmentStatePagerAdapter {

    private List<TechnologyTypeBean> list;

    public TechnologyViewPagerAdapter(FragmentManager fm) {
        super(fm);
        list = new ArrayList<>();
    }

    public void updateData(List<TechnologyTypeBean> list){
        this.list.addAll(list);
        notifyDataSetChanged();
    }

    @Override
    public Fragment getItem(int position) {
        return TechnologyListFragment.newInstance(list.get(position).getCatId());
    }

    @Override
    public int getCount() {
        return list == null ? 0 : list.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return list.get(position).getCatName();
    }
}
